package bmptest.bmp.common;

import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author lyq
 * @date 2021/9/6 9:36
 * 基础工具类
 */

public class CommonUtils {

    //从session获取当前登录用户id
    public String getSessionUserid(HttpSession session){
        String user_id = (String)session.getAttribute("user_id");
        return user_id;
    }

    //从session获取当前登录用户名称
    public String getSessionUsername(HttpSession session){
        String user_name = (String)session.getAttribute("user_name");
        return user_name;
    }

    //获取对当前时间
    public String getCurrentDate(){
        SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date(System.currentTimeMillis());
        String currentDate = formatter.format(date);
        return currentDate;
    }

}
